<template>
	<view class="beijingse mainpadding">
		<view class="mainpadding ffffff radius flexbetween">
			<view class="ershiba xiaohei fonweight">旧密码</view>
			<input class="input" type="number" placeholder="请输入旧密码" v-model="password">
		</view>
		<view class="mainpadding ffffff radius flexbetween margin_top">
			<view class="ershiba xiaohei fonweight">新密码</view>
			<input class="input" type="number" placeholder="请输入新密码" v-model="newpassword">
		</view>
		<view class="mainpadding ffffff radius flexbetween margin_top">
			<view class="ershiba xiaohei fonweight">新密码</view>
			<input class="input" type="number" placeholder="请再次输入新密码"  v-model="newpasswordt">
		</view>
		<view class="gudingdb mainpadding">
			<view class="bigbtn"  @click="submit">确认修改</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				password:"",
				newpassword:"",
				newpasswordt:""
			}
		},
		methods: {
			submit(){
				
				if(this.password==""){
					httpRequest.toast("请输入旧密码")
					return false
				}
				if(this.newpassword==""){
					httpRequest.toast("请输入新密码")
					return false
				}
				if(this.newpasswordt==""){
					httpRequest.toast("请再次输入新密码")
					return false
				}
				if(this.newpasswordt!=this.newpassword){
					httpRequest.toast("两次密码输入不一致")
					return false
				}
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/user/changepwd', 'GET', {
					password:this.password,
					newpassword:this.newpassword
				}).then(res => {
					uni.hideLoading()
					if(res.code==1){
						uni.clearStorageSync()
						httpRequest.toast("修改密码成功，已自动为您退出登录")
						setTimeout(() => {
							uni.navigateBack({
								delta:2
							})
						}, 1000)
					}else{
						httpRequest.toast(res.msg)
					}
					
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	
	.line{
		margin: 0 20rpx;
	}
	.input{
		text-align: right;
		width: 220rpx;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
	.line {
		width: 1rpx;
		height: 20rpx;
		background-color: #999999;
	}
</style>